#pragma once
#include "spritecomponent.h"
#include "BezierCurve.h"

#define MAX_HOSTAGES 6
class CCarManager;

class CCar :
	public CSpriteComponent
{
protected: //the car points its headlights down the x-axis,
			//with the driver-side door facing down -z-axis
	double _clength; //x-axis length
	double _cwidth; //z-axis width
	double _cheight; //height of box of car
	double _floorLift; //height of the inside floor above the car floor (bottom)
	double _wheelR; //the radius of the spherical wheels

	double _peopleR; //the radius of a person's head (i don't draw the body)
	double _peoplePadX; //extra padding between people's seats (x-axis padding)
	double _peoplePadZ; //same padding only z-axis padding

	int _numHostages;
	double _velocity; //speed at which we trace our bezier curve
	double _bezierTravel; //our 'position' as defined by _velocity and the bcurve
	CGrVector _lastPositions[10]; //used to calculate the direction
	int _lastPCounter;
	void addPosition(CGrVector lp);
	CBezierCurve _bcurve;
	CCarManager *_manager;

	void DrawBody();
	void DrawWheels();
	void DrawPeople();


public:
	CCar(void);
	virtual ~CCar(void);

	virtual void Render();
	virtual void Update(double dt);
	void setHostageCount(int n) { _numHostages = (n > MAX_HOSTAGES) ? MAX_HOSTAGES : n; }
	int getHostageCount() { return _numHostages; }
	void setVelocity(double v) { _velocity = v; }
	double getVelocity() { return _velocity; }
	void setBezierCurve(CBezierCurve bc) { _bcurve = bc; _position = _bcurve.FindPoint(0);}
	void setManager(CCarManager *cm) { _manager = cm; }
};
